<template>
    <div>
        <!--查询条件start --111s-->
        <el-card>
        <el-form :inline="true" :model="query" class="query-form" size="small">
            <el-form-item>
                <el-date-picker
                    v-model="createTime"
                    unlink-panels
                    type="datetimerange"
                    :picker-options="pickerOptions"
                    range-separator="-"
                    start-placeholder="请输入开始日期"
                    end-placeholder="请输入结束日期"
                    align="left"
                    format="yyyy-MM-dd HH:mm:ss"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    :default-time="['00:00:00','23:59:59']"
                    @change="dateChange"
                ></el-date-picker>
            </el-form-item>
            <el-form-item class="query-form-item" label="商品查询：">
                <el-input
                    v-model="query.searchtext"
                    placeholder="请输入商品名称"
                    prefix-icon="el-icon-search"
                    @keyup.enter.native="onSubmit"
                    clearable
                ></el-input>
            </el-form-item>
            <el-form-item class="query-form-item" label="商家名称：">
                <el-input
                    v-model="query.enterprisename"
                    placeholder="请输入商家名称"
                    prefix-icon="el-icon-search"
                    @keyup.enter.native="onSubmit"
                    clearable
                ></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-refresh" @click="onRest"></el-button>
                <el-button type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
            </el-form-item>
        </el-form>
        <el-form :inline="true" :model="query" class="query-form" size="small">
            <el-form-item label="品控审核状态：">
                <el-select v-model="query.commoditystatus" placeholder="请选择状态" @change="getList()" clearable>
                    <el-option label="待审核" value="0"></el-option>
                    <el-option label="已通过" value="1"></el-option>
                    <el-option label="已驳回" value="2"></el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <!--列表start --222s-->
        <el-table
            v-loading="loading"
            :data="list"
            :header-cell-style="{background:'#F4F4F5',color:'#606266'}"
            border
        >
            <el-table-column label="商品ID" prop="commodityid" width="70" align="center"/>
            <el-table-column label="商品图片" prop="commodityicon" align="center" width="100">
                <template slot-scope="scope">
                    <el-popover v-if="scope.row.commodityicon" placement="right" trigger="hover">
                        <img :src="scope.row.commodityicon" style="width:400px;border-radius:3px;">
                        <img slot="reference" :src="scope.row.commodityicon" style="max-height: 80px;max-width: 50px;border-radius:5px;" >
                    </el-popover>
                    <span v-else>-</span>
                </template>
            </el-table-column>
            <el-table-column label="商品名称" prop="commodityname"  align="center" width="150"/>
            <el-table-column label="商家名称" prop="enterprisename" width="200" align="center"/>
            <el-table-column label="一级分类" prop="topcategoryname" width="150" align="center"/>
            <el-table-column label="二级分类" prop="secondarycategoryname" width="150" align="center"/>
            <el-table-column label="三级分类" prop="thirdcategoryname" width="150" align="center"/>
            <el-table-column label="库存" prop="commoditynum" width="100" align="center"/>
            <el-table-column label="品控审核状态" width="120" align="center">
                <template slot-scope="scope">
                    <el-tag v-if="scope.row.qualityStatus == 0">待审核</el-tag>
                    <el-tag type="success" v-if="scope.row.qualityStatus == 1">已通过</el-tag>
                    <el-tag type="danger" v-if="scope.row.qualityStatus == 2">已驳回</el-tag>
                </template>
            </el-table-column>
            <el-table-column label="招商审核状态" width="120" align="center">
                <template slot-scope="scope">
                    <el-tag v-if="scope.row.canvassStatus == 0">待审核</el-tag>
                    <el-tag type="success" v-if="scope.row.canvassStatus == 1">已通过</el-tag>
                    <el-tag type="danger" v-if="scope.row.canvassStatus == 2">已驳回</el-tag>
                </template>
            </el-table-column>
            <el-table-column label="上架" prop="onshelfstatus" align="center" width="120">
                <template slot-scope="scope">
                    <span>{{ scope.row.onshelfstatus==='1'?'上架':'下架'}}</span>
                </template>
            </el-table-column>
            <el-table-column label="推荐" prop="recommendstatus" align="center" width="120">
                <template slot-scope="scope">
                    <span>{{ scope.row.recommendstatus=='1'? '推荐':'不推荐'}}</span>
                </template>
            </el-table-column>
            <el-table-column label="添加时间" width="180"  :show-overflow-tooltip="true" align="center">
                <template slot-scope="scope">
                    <i class="el-icon-time" v-if="scope.row.createtime!=null"></i>
                    <span  v-if="scope.row.createtime!=null" >{{ scope.row.createtime | formatDateStr('yyyy-MM-dd hh:mm:ss') }}</span>
                </template>
            </el-table-column>
            <el-table-column label="操作" width="120" align="center" fixed="right">
                <template slot-scope="scope">
                    <el-button v-if="scope.row.qualityStatus == 0" type="primary" size="mini" @click.native="detailForm(scope.$index, scope.row)">审核</el-button>
                    <el-button v-else type="primary" size="mini" @click.native="detailForm(scope.$index, scope.row)">查看</el-button>
                </template>
            </el-table-column>
        </el-table>
        <!--列表end --222e-->
        <!--分页模块start-->
        <el-pagination
            class="pagination-container"
            background
            :page-size="query.pageSize"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            layout="total,sizes,prev, pager, next, jumper"
            :current-page="query.currentPage"
            :page-sizes="[5, 10, 20, 30, 50]"
            :total="totalNumber"
        ></el-pagination>
        <!--分页模块end-->

        <!--查看弹框-->
        <el-dialog
            title="查看详情"
            :visible.sync="detailVisible"
            :before-close="hideDetailForm"
            width="50%"
            top="5vh"
            v-dialogDrag
            :close-on-click-modal="false"
        >
        <template slot="title">
            <div class="avue-crud__dialog__header">
                <span class="el-dialog__title">
                    <span style="display:inline-block;background-color: #3478f5;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px"></span>
                    查看详情
                </span>
                <div class="avue-crud__dialog__menu" >
                    <icon-svg icon-class="quanping" /> 
                    <span  class="mention">双击全屏</span>
                </div>
            </div>
        </template>
        <el-card>
            <el-form :model="formData" label-width="120px">
                <el-form-item label-width="120px" label="审核" style="background: #e1e1e1"></el-form-item>
                <el-form-item label-width="0" style="background: #e1e1e1">
                    <el-table v-loading="tableLoading" :data="qualityList" :header-cell-style="{background:'#F4F4F5',color:'#606266'}" border>
                        <el-table-column label="品控审核状态" align="center">
                            <template slot-scope="scope">
                                <el-tag v-if="scope.row.certificationstatus == 0">待审核</el-tag>
                                <el-tag type="success" v-if="scope.row.certificationstatus == 1">已通过</el-tag>
                                <el-tag type="danger" v-if="scope.row.certificationstatus == 2">已驳回</el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column label="驳回原因" prop="rejectreason" :show-overflow-tooltip="true" align="center"/>
                        <el-table-column label="审核时间"  :show-overflow-tooltip="true" align="center">
                            <template slot-scope="scope">
                                <i class="el-icon-time" v-if="scope.row.operationtime!=null"></i>
                                <span  v-if="scope.row.operationtime!=null" >{{ scope.row.operationtime | formatDateStr('yyyy-MM-dd hh:mm:ss') }}</span>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-form-item>    
                <el-form-item label-width="0" style="background: #e1e1e1">
                    <el-table v-loading="tableLoading" :data="canvassList" :header-cell-style="{background:'#F4F4F5',color:'#606266'}" border>
                        <el-table-column label="招商审核状态" align="center">
                            <template slot-scope="scope">
                                <el-tag v-if="scope.row.certificationstatus == 0">待审核</el-tag>
                                <el-tag type="success" v-if="scope.row.certificationstatus == 1">已通过</el-tag>
                                <el-tag type="danger" v-if="scope.row.certificationstatus == 2">已驳回</el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column label="驳回原因" prop="rejectreason" :show-overflow-tooltip="true" align="center"/>
                        <el-table-column label="审核时间"   :show-overflow-tooltip="true" align="center">
                            <template slot-scope="scope">
                                <i class="el-icon-time" v-if="scope.row.operationtime!=null"></i>
                                <span  v-if="scope.row.operationtime!=null" >{{ scope.row.operationtime | formatDateStr('yyyy-MM-dd hh:mm:ss') }}</span>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-form-item>   
                <el-form-item label-width="120px" label="基本参数" style="background: #e1e1e1"></el-form-item>
                <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">
                    <el-form-item label="商品名称：" style="width:30%;display: inline-block;">
                        <input v-model="formData.commodityname" type="text" readonly>
                    </el-form-item>
                    <el-form-item label="商品分类："  style="margin-left:80px; width:50%;display: inline-block;">
                        <span>{{formData.topcategoryname+","+formData.secondarycategoryname+","+formData.thirdcategoryname}}</span>
                    </el-form-item>    
                </el-form-item>
                <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                    <el-form-item label="经销价：" style="width:30%;display: inline-block;">
                        <input v-model="formData.commodityoldprice" type="text" readonly>
                    </el-form-item>
                    <el-form-item label="零售价：" style="margin-left:80px; width:30%;display: inline-block;">
                        <input v-model="formData.commodityprice" type="text" readonly>
                    </el-form-item>

                </el-form-item>
                <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">
                    <el-form-item label="商品ID：" style="width:30%;display: inline-block;">
                        <span>{{formData.commodityid}}</span>
                    </el-form-item>
                    <el-form-item label="添加时间：" style="margin-left:80px; width:30%;display: inline-block;">
                        <span>{{formData.createtime | formatDateStr('yyyy-MM-dd')}}</span>
                    </el-form-item>
                </el-form-item>
                <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">
                    <el-form-item label="上架状态："  style="width:30%;display: inline-block;">
                        <span>{{ formData.onshelfstatus==='1'?'上架':'未上架'}}</span>
                    </el-form-item>
                    <el-form-item label="库存：" style="margin-left:80px; width:30%;display: inline-block;">
                        <input v-model="formData.commoditynum" type="text" readonly>
                    </el-form-item>
                </el-form-item>
                <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">
                    <el-form-item label="封面图：" style="width:30%;display: inline-block">
                        
                        <el-popover v-if="formData.commodityicon" placement="right" trigger="hover">
                            <img :src="formData.commodityicon" style="width:400px;border-radius:3px;">
                            <img
                                slot="reference"
                                :src="formData.commodityicon"
                                style="max-height: 80px;max-width: 50px;border-radius:5px;"
                            >
                        </el-popover>
                        <span v-else>-</span>

                    </el-form-item>

                </el-form-item>

                 <!-- 商品属性-->
                <el-form-item label-width="80px" label="商品属性" style="background: #e1e1e1" />
                <span v-if="attributecontenct.length !=0 && attributecontenct !=null">
                <h3 style="height: 50px; margin-left: 40px" class="thrTitle" >基本属性</h3>
                <div :prop="'fieldname' + index" v-for="(item, index) in attributecontenct" :key="item.id">
                    <el-form-item label-width="180px" :label="item.fieldname + '：'">
                    <el-input
                        v-model.trim="formData1[item.fieldname]"
                        v-if="item.fieldtype == '文字'"
                        type="text"
                        :disabled="true"
                        maxlength="10"
                        :placeholder="'请填写' + item.fieldname"
                    ></el-input>
                    <el-input
                        v-model.trim="formData1[item.fieldname]"
                        v-if="item.fieldtype == '数字'"
                        :disabled="true"
                        type="number"
                        maxlength="10"
                        :placeholder="'请填写' + item.fieldname"
                    ></el-input>
                    
                    </el-form-item>
                </div>
                </span>

                <span v-if="attributeextendcontenct.length !=0 && attributeextendcontenct !=null">
                <h3 style="height: 50px; margin-left: 40px" class="thrTitle"  >扩展属性</h3>
                <div
                    :prop="'extendfieldname' + index"
                    v-for="(item, index) in attributeextendcontenct"
                    :key="item.id"
                >
                    <el-form-item
                    label-width="180px"
                    :label="item.extendfieldname + '：'"
                    >
                    <el-input
                        v-model.trim="formData1[item.extendfieldname]"
                        @input="onInput2()"
                        @change="changeInput2(item)"
                        v-if="item.fieldtype == '文字'"
                        :disabled="true"
                        type="text"
                        maxlength="10"
                        :placeholder="'请填写' + item.extendfieldname"
                    ></el-input>
                    <el-input
                        v-model.trim="formData1[item.extendfieldname]"
                        @input="onInput2()"
                        @change="changeInput2(item)"
                        v-if="item.fieldtype == '数字'"
                        :disabled="true"
                        type="number"
                        maxlength="10"
                        :placeholder="'请填写' + item.extendfieldname"
                    ></el-input>
                    
                    </el-form-item>
                </div>
                </span>
                <el-form-item label-width="120px" label="商品资质认证" style="background: #e1e1e1">
                </el-form-item>
                <span v-if="categoryTemplate != [] && categoryTemplate != null">
                    <h3 class="thrTitle" style="height:50px">{{categoryTemplate.name || ""}}</h3>
                    <el-form-item :label="item.fieldname+'：'" label-width="180px" :prop="'fieldname'+index" v-for="(item,index) in categoryTemplate.templateItemFormList" :key="item.id">
                        <input type="hidden" v-model="item.fieldvalue">
                        <el-input v-model="formData4[item.fieldname]" @input="onInput()" @change="changeInput(item)" v-if="item.fieldtype == '文字'" type="text" :placeholder="'请填写'+item.fieldname" disabled></el-input>
                        <el-input v-model="formData4[item.fieldname]" @input="onInput()" @change="changeInput(item)" v-if="item.fieldtype == '数字'" type="number" :placeholder="'请填写'+item.fieldname" disabled></el-input>

                        <el-popover v-if="item.fieldtype == '图片'" placement="right" trigger="hover">
                            <img :src="item.fieldvalue" style="width:400px;border-radius:3px;">
                            <img slot="reference" :src="item.fieldvalue" style="max-height: 80px;max-width: 150px;border-radius:5px;">
                        </el-popover>
                    </el-form-item>

                </span>
                <!--商品规格-->
                <el-form-item label-width="110px" label="规格参数" style="background: #e1e1e1"></el-form-item>
                <el-table
                    ref="multipleTable"
                    v-loading="loading"
                    :data="parameterlist"
                    :header-cell-style="{background:'#F4F4F5',color:'#606266'}"
                    border  
                >
                   
                    <!--商品规格-->
                    <el-table-column label="商品图片" width="100"  align="center">
                        <template slot-scope="scope">
                            <el-popover v-if="scope.row.inventorypic" placement="right" trigger="hover">
                                <img :src="scope.row.inventorypic" style="width:400px;border-radius:3px;">
                                <img
                                    slot="reference"
                                    :src="scope.row.inventorypic"
                                    style="max-height: 80px;max-width: 50px;border-radius:5px;"
                                >
                            </el-popover>
                            <span v-else>-</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="规格参数" align="center">
                        <el-table-column v-for="(item,index) in inputData" :key="index" :label='item.key' width="150" align="center">
                            <template slot-scope="scope">
                                <div v-if="scope.row.splist!==undefined">
                                    <el-select v-model="scope.row.splist[index]" placeholder="请选择" disabled  ref="sel" >
                                        <el-option
                                            v-for="(it,ind) in (item.val.split(','))"
                                            :key="ind"
                                            :label="it"
                                            :value="it">
                                        </el-option>
                                    </el-select>
                                </div>
                            </template>
                        </el-table-column>
                    </el-table-column>
                    <el-table-column label="成本价" prop="costprice"  align="center"/>
                    <!--                    <el-table-column label="代理价" prop="primaryagentprice"  align="center"/>-->
                    <el-table-column label="经销价" prop="secondaryagentprice"  align="center"/>
                    <el-table-column label="分销价" prop="commodityprice"  align="center"/>
                    <el-table-column label="零售价" prop="commodityoldprice" align="center"/>
                    <!-- <el-table-column label="推广比例(%)" prop="profitproportion" align="center" width="150"/> -->
                    <el-table-column label="推广比例(%)" prop="profitproportion" width="150" align="center">
                        <template slot-scope="scope">
                            <el-input-number style="width: 120px;" v-model="scope.row.profitproportion" align="center" disabled
                            :min="0" :controls="false" :precision="4" ></el-input-number>

                        </template>
                    </el-table-column>
                    <el-table-column label="库存" prop="inventorynum" width="150" align="center"/>
                </el-table>
            <el-form-item label-width="120px" label="商品轮播图" style="background: #e1e1e1;margin-top:20px;"></el-form-item>
                <el-form-item >
                    <div v-for="(item,index) in formData.commoditypiclist" :key="index" style="display:inline-block;">
                        <img :src="item" style="width:200px;border-radius:3px;margin-left: 5px;">
                    </div>
                </el-form-item>
            <el-form-item label-width="120px" label="商品详情" style="background: #e1e1e1;margin-top:20px; "></el-form-item>
                
                <span v-html="formData.commoditydesc" style="margin-left:10%;display:block;"></span>
                
            </el-form>
            <div style="text-align:right">
                
                <el-button size="small" v-if="formData.qualityStatus == 0" type="danger" @click="dialogFormVisible1=true" :loading='loading'>驳 回</el-button>
                <el-button size="small" v-else  type="danger" @click="dialogFormVisible1=true" :loading='loading' disabled>驳 回</el-button>
                <el-button size="small" v-if="formData.qualityStatus == 0" type="primary" @click="passApplication" :loading='loading' >审核通过</el-button>
                <el-button size="small" v-else type="primary" @click="passApplication" :loading='loading' disabled>审核通过</el-button>
                <el-button size="small" @click="detailVisible = false">取 消</el-button>
            </div>
            </el-card>
            
        </el-dialog>
        </el-card>
        <!-- 商家入驻驳回 -->
        <el-dialog  title="请填写驳回原因" :visible.sync="dialogFormVisible1" width="50%" top="5vh" v-dialogDrag>
          <el-form>
            <el-form-item label="驳回原因：">
              <el-input
                type="textarea"
                style="width: 80%"
                maxlength="300"
                show-word-limit
                :autosize="{ minRows: 4, maxRows: 10 }"
                v-model="reasonsSettlement"
              ></el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible1 = false">取 消</el-button>
            <el-button type="primary" @click="rejectSettlement" :loading='loading'>确 定</el-button>
          </div>
        </el-dialog>
    </div>
</template>
<script>
    import {
  getMainCommodityAudit,
  mainCommodityToExamine,
  queryCommodityAuditList

} from '../../api/classification/classification.js'
    export default {
        data() {
            return {
                pickerOptions: {//快速选择日期
                    shortcuts: [
                        {
                            text: "最近一周",
                            onClick(picker) {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(
                                    start.getTime() - 3600 * 1000 * 24 * 7
                                );
                                picker.$emit("pick", [start, end]);
                            }
                        },
                        {
                            text: "最近一个月",
                            onClick(picker) {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(
                                    start.getTime() - 3600 * 1000 * 24 * 30
                                );
                                picker.$emit("pick", [start, end]);
                            }
                        },
                        {
                            text: "最近三个月",
                            onClick(picker) {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(
                                    start.getTime() - 3600 * 1000 * 24 * 90
                                );
                                picker.$emit("pick", [start, end]);
                            }
                        },
                        {
                            text: "最近六个月",
                            onClick(picker) {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(
                                    start.getTime() - 3600 * 1000 * 24 * 180
                                );
                                picker.$emit("pick", [start, end]);
                            }
                        }
                    ]
                },
                formData1:{},
                attributecontenct:[],//商品属性
                attributeextendcontenct:[],//商品属性模板
                formData4: {
                    // 第四步表单
                    storename: null, // 店铺名称
                    enterinfoid: null, // 主键
                    certificationcontent: null, // 商品分类模板
                    topcategoryid: null, // 一级商品分类id
                    secondarycategoryid: null, // 二级商品分类id
                    categoryid: null // 三级商品分类id
                },
                query: {//查询条件
                    enterprisename: "",//商家名称
                    startDate: "",
                    endDate: "",
                    searchtext: "",//商品名称
                    currentPage: 1,
                    pageSize: 5,
                    commoditystatus:"",
                    operationtype:2
                },
                formData: {},//新增或修改的对象
                formName: '',
                createTime: [],//选择日期时需要的model
                list: [],//列表集合
                inputData: [],// 循环创建input存值
                totalNumber: 0,//分页总页数
                loading: true,//列表加载
                detailVisible: false,//查看
                categoryTemplate: [], // 商品类目模板,
                parameterlist:[],
                reasonsSettlement: '', // 商家入驻驳回理由
                dialogFormVisible1:false,//商家入驻驳回弹窗
                canvassList:[],//招商列表
                qualityList:[],//品控列表
                tableLoading:false
            };
        },
        methods: {
            /// 商品审核驳回列表
            queryCommodityAuditList(){
                this.tableLoading=true
                 let merchantsForm={
                      commodityid:this.formData.commodityid,
                      operationtype :'0',
                    }
                 queryCommodityAuditList(merchantsForm)
                    .then((res) => {
                      if (res.code != 0) {
                        this.$message.error(res.message)
                        return false
                      }
                      this.canvassList=res.data.canvassList
                      this.qualityList=res.data.qualityList
                      this.tableLoading=false
                    })
                    .catch(() => {
                        this.tableLoading=false
                    })
            },
            //商家通过审核
            passApplication(){
                this.$confirm('确定要通过审核?', '提示', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'
                }).then(() => {
                    let merchantsForm={
                      commodityid:this.formData.commodityid,
                      certificationstatus:1,
                      operationtype:2 //招商：1，品控：2
                    }
                    mainCommodityToExamine(merchantsForm)
                    .then((response) => {
                      if (response.code != 0) {
                        this.$message.error(response.message)
                        return false
                      }
                      this.$message.success('通过审核！')
                      this.dialogFormVisible1 = false
                      this.detailVisible = false
                      this.onRest()
                      setTimeout(() => {
                        this.loading = false
                      }, 0.3 * 1000)
                    })
                    .catch(() => {
                      this.loading = false
                    })
                }).catch(() => {
                  this.$message({
                    type: 'info',
                    message: '已取消'
                  });          
                });
        
            },
            // 商家入驻驳回
            rejectSettlement() {
              if (!this.reasonsSettlement) {
                this.$message.warning('请填写驳回原因！！！')
                return false
              }
              this.loading = true
              let merchantsForm={
                  commodityid:this.formData.commodityid,
                  certificationstatus:2,
                  rejectreason:this.reasonsSettlement,
                  operationtype:2   //招商：1，品控：2
              }
              mainCommodityToExamine(merchantsForm)
                .then((response) => {
                  if (response.code != 0) {
                    this.$message.error(response.message)
                    return false
                  }
                  this.$message.success('审核已被驳回！')
                  this.dialogFormVisible1 = false
                  this.detailVisible = false
                  this.onRest()
                  setTimeout(() => {
                    this.loading = false
                  }, 0.3 * 1000)
                })
                .catch(() => {
                  this.loading = false
                })
            },
            //查看评论
            lookcomment(v) {

                this.$router.push({path: '/commodity/comment', query: {cid: v}})
                // alert(v)
            },
            //显示 查看弹框
            detailForm(index, row) {
                // debugger;
                this.detailVisible = true;
                this.attributecontenct=[];
                this.attributeextendcontenct=[]
                if (row !== null) {
                    this.inputData=[]
                    this.formData = Object.assign({}, row);
                    this.formData.secondarycategoryid=row.secondarycategoryid;
                    this.formData.thirdcategoryid=row.thirdcategoryid;
                    //处理商品属性模板
                    if (row.attributecontenct != null) {
                        this.attributecontenct = JSON.parse(row.attributecontenct);
                        this.formData.attributecontenct = JSON.parse( row.attributecontenct );
                        if ( this.attributecontenct != null && this.attributecontenct != undefined) {
                                this.attributecontenct .forEach((item) => {
                                    this.formData1[item.fieldname] = item.fieldvalue;
                                });
                        }
                    }
                    if (row.attributeextendcontenct != null) { 
                        this.attributeextendcontenct = JSON.parse(row.attributeextendcontenct);
                        this.formData.attributeextendcontenct = JSON.parse(row.attributeextendcontenct);
                        if ( this.attributeextendcontenct != null && this.attributeextendcontenct != undefined) {
                                this.attributeextendcontenct.forEach((item) => {
                                    this.formData1[item.extendfieldname] = item.fieldvalue;
                                });
                        }
                    }
                    if(row.certificationcontent!=null){
                        this.categoryTemplate = JSON.parse(row.certificationcontent);
                        this.formData.certificationcontent = JSON.parse(row.certificationcontent);
                        if(this.categoryTemplate.templateItemFormList!=null&&this.categoryTemplate.templateItemFormList!=undefined){
                            this.categoryTemplate.templateItemFormList.forEach(item => {
                                    // item.fieldvalue = this.formData4[item.fieldname];
                                    this.formData4[item.fieldname] = item.fieldvalue;
                                }
                            );
                        }
                    }
                    // this.formData.commoditytype=row.commoditytype+"";
                    if(row.inventorylist!=null&&row.inventorylist[0].inputdata!=null){
                        this.inputData=JSON.parse(row.inventorylist[0].inputdata);
                    }else{
                        let data={
                            key:"",
                            val:""
                        }
                        this.inputData.push(data);
                    }
                }
                let data=[];
                let pic=[];
                let vdata=[];
                let vpic=[];
                for (let i=0;i<row.commoditypiclist.length;i++){
                    let picdata=row.commoditypiclist[i];
                    if(picdata.recoursetype===0){
                        let obj={
                            name:"",
                            url:""
                        }
                        obj.name=i;
                        obj.url=picdata.picurl;
                        data.push(obj);
                        pic.push(picdata.picurl)
                    }
                    if(picdata.recoursetype===1){

                        let obj={
                            name:"",
                            url:""
                        }
                        obj.name=i;
                        obj.url=picdata.picurl;
                        vdata.push(obj);
                        vpic.push(picdata.picurl)
                    }
                }
                this.formData.videopic=vpic;
                this.formData.commoditypiclist=pic;
                this.parameterlist=row.inventorylist;
                
                for(let i=0;i<this.parameterlist.length;i++){
                    let sav=[];
                    this.$set(this.parameterlist[i], "savparameterlist", sav);
                    this.$set(this.parameterlist[i], "splist", sav);

                    var a=this.parameterlist[i].inventory.indexOf("}");
                    var b=this.parameterlist[i].inventory.substring(1,a)
                    var a1=b.split(",");
                    var splist1=[];
                    for (let c=0;c<a1.length;c++) {
                        var s=a1[c].split(":")[1].substring(1,a1[c].split(":")[1].length-1);
                        splist1.push(s)
                    }
                    //县域百分比回显
                    if( this.parameterlist[i].profitproportion<1){
                        (this.parameterlist[i].profitproportion)*= 100;
                    }else{
                        (this.parameterlist[i].profitproportion)
                    }
                    this.parameterlist[i].splist=(splist1);
                    this.parameterlist[i].savparameterlist=JSON.parse(this.parameterlist[i].secinventory);

                    this.parameterlist[i].companytype= this.parameterlist[i].companytype.toString();
                }
                //参数
                let sav=[];
                if(this.parameterlist!=null&&this.parameterlist.length>0){

                    for(let i=0;i<this.parameterlist.length;i++){
                        let pdata=JSON.parse(this.parameterlist[i].secinventory);

                        console.info(pdata)

                        for (let i=0;i<pdata.length;i++) {
                            let mdata=pdata[i]
                            for (let v in mdata){
                                let data={
                                    key:v,
                                    val:mdata[v].toString()
                                }
                                sav.push(mdata[v].toString());
                            }
                        }
                        this.parameterlist.savparameterlist=pdata;
                    }
                    this.parameterlist.splist=sav;
                }
                this.formName = "detail";
                this.queryCommodityAuditList()
            },
            // 隐藏详情弹框
            hideDetailForm() {
                // 更改值
                this.detailVisible = !this.detailVisible;
                // 清空表单
                this.formData={};
                return true;
            },
            shelfstatus(){
               
            },
            /*获取列表事件*/
            getList() {
                this.loading = true;
                this.list = [];
                getMainCommodityAudit(this.query).then(response => {
                    if (response.code != 0) {
                        this.$message.error(response.message);
                        return false;
                    }
                    let datalist = response.data.list || []
                    if (datalist.length > 0) {
                        let mylist = datalist
                        for (var i = 0; i < mylist.length; i++) {
                            if (mylist[i].recommendstatus != null) {
                                mylist[i].recommendstatus = mylist[i].recommendstatus.toString();
                            }
                            if(mylist[i].belongtype==0){//平台
                                mylist[i].companyName="平台"
                            }
                            if(mylist[i].canvassStatus==null){
                                mylist[i].canvassStatus=mylist[i].commoditystatus
                            }
                            if(mylist[i].qualityStatus==null){
                                mylist[i].qualityStatus=mylist[i].commoditystatus
                            }
                        }
                        this.list = mylist
                    }
                    this.totalNumber = response.data.totalNumber || 0;
                    setTimeout(() => {
                        this.loading = false;
                    }, 0.3 * 1000);
                }).catch(() => {
                    this.loading = false;
                    this.list = [];
                })
            },

            /*日期选择事件*/
            dateChange(val) {
                if (val == null) {
                    this.query.startDate = "";
                    this.query.endDate = "";
                } else {
                    this.query.startDate = val[0];
                    this.query.endDate = val[1];
                    this.query.currentPage = 1;
                }
                this.getList();
            },
            /*列表查询条件事件*/
            onSubmit() {
                this.query.currentPage = 1;
                this.getList();
            },

            /*刷新*/
            onRest() {
                //刷新事件需要重置查询条件
                this.createTime = [];
                this.query = {
                    enterprisename: "",//商家名称
                    startDate: "",
                    endDate: "",
                    searchtext: "",//商品名称
                    currentPage: 1,
                    pageSize: 5,
                    commoditystatus:"",
                    operationtype:2
                };
                this.getList();
            },

            /*点击页数*/
            handleCurrentChange(val) {
                this.query.currentPage = val;
                this.getList();
            },

            /*选择每页条数【10,20,30,40,50】*/
            handleSizeChange(val) {
                this.query.pageSize = val;
                this.getList();
            },
        },

        created() {
            this.getList();
        }
    }

</script>
<style type="text/css" scoped>
    .avatar-uploader .el-upload {
        border: 1px dashed #d9d9d9;
        border-radius: 6px;
        cursor: pointer;
        position: relative;
        overflow: hidden;
    }

    .avatar-uploader .el-upload:hover {
        border-color: #409EFF;
    }

    .avatar-uploader-icon {
        font-size: 21px;
        color: #8c939d;
        width: 50px;
        height: 50px;
        line-height: 178px;
        text-align: center;
    }

    .avatar {
        width: 178px;
        height: 178px;
        display: block;}
    .thrTitle {
        margin-left: 60px;
        font-size: 16px;
        font-weight: 600;
    }
</style>

